/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Dialogos;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import sun.misc.FormattedFloatingDecimal;

/**
 *
 * @author Pedro
 */
public class ParamAngulo extends JDialog
{

    JButton botaoOk;
    JButton botaoCancelar;
    JTextField angulos;
    JLabel label;
    private boolean ok;
    public ParamAngulo(JFrame owner)
    {
        super(owner, "Digite os parâmetros!");
        this.setLayout(new BorderLayout());
        JPanel p1 = new JPanel();
        p1.setLayout(new GridLayout(1, 2));
        JPanel p2 = new JPanel();
        p2.setLayout(new GridLayout(1,2));

        botaoOk = new JButton("OK");
        botaoOk.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setOk(true);
                dispose();
            }
        });
        botaoCancelar = new JButton("Cancelar");
        botaoCancelar.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setOk(false);
                dispose();
            }
        });
        label = new JLabel("Ângulo em graus:");
        angulos = new JTextField();



        p1.add(label);
        p1.add(angulos);
        p2.add(botaoOk);
        p2.add(botaoCancelar);
        this.add(p1,BorderLayout.CENTER);
        this.add(p2,BorderLayout.SOUTH);
        this.setSize(new Dimension(300,100));
        this.setModal(true);
        this.setVisible(true);

    }

    /**
     * @return the ok
     */
    public boolean isOk() {
        return ok;
    }

    /**
     * @param ok the ok to set
     */
    public void setOk(boolean ok) {
        this.ok = ok;
    }

    public double retornaRadianos()
    {
        double graus = Double.parseDouble(angulos.getText());
        return ((graus * 2)*Math.PI) / 360;
    }

}
